<?php
/**
 *
 *
 * @package
 * @subpackage
 * @author J.Ducastel <nospam0@ducastel.name>
 */

class TestDjStore_Db_Blog extends UnitTestCase {

    public function setup() {
        // opening a link
        // $link = DbLinkTool::toolFactory('webappkit.admin');
    }

    /* test methods */

    /**
     * should be able to save any object
     */
    function test_get1() {
        $store = $this->_store();
        // $this->dump($store);
        $post = $store->get(1);
        $this->assertIsA($post, 'DjBlogPost');
        $this->assertEqual($post->title, 'Hello World !', "post->title should return the good string value");

    }

    function testInsert() {
        $store = $this->_store();
        $post = new DjBlogPost();
        $post->title = 'A brand new post';
        $this->assertTrue($store->insert($post), "store->insert() should return true");
        $this->assertNotNull($post->id, "post->id should have been set");
    }

    /* utility methods */

    function _store() {
        $cfg = array('model' => 'DjBlogPost');
        return DjStore_Db::toolFactory('dj.models', $cfg);
    }

}